import os
import time

source = ['E:\\QF','E:\\QFWebsite']
target_dir = 'E:\\'

today = target_dir + time.strftime('%Y%m%d')
now = time.strftime('%H%M%S')

comment = raw_input('Enter a comment:')
if len(comment) == 0:
	target = today + os.sep + now + '.rar'
else:
	target = today + os.sep + now + '_' +\
	comment.replace(' ','_') + '.rar'
 
if not os.path.exists(today):
	os.mkdir(today)
	print 'Successfully created directory',today

rar_command = r'"C:\Program Files\WinRAR\Rar.exe" a %s %s' %(target, ' '.join(source))


if os.system(rar_command) == 0:
	print 'Successfully backup to', target
else:
	print 'Backup Failed'